/*
 * linux api : alarm()
 * 
 * one time timer api,after second ,the generate SIGALARM signal one time
 * unsigned int alarm(unsigned int seconds)
 * return : previously timer remainning number seconds
 * ************************************************
 * note :alarm settitimer() share same timer, so we should use aralm settitimer only one api in process
 */

#include <unistd.h>
#include <signal.h>
#include <stdio.h>
void sig_handler(int signo)
{
    printf("alarm now\n");
    //re-eneable alarm
    alarm(1);
}

int main()
{
    signal(SIGALRM, sig_handler);
    alarm(3);
    pause();

    printf("signal done\n");
    while (1)
    {
    }
    //   printf("exit\n");
    return 0;
}
